package com.sky.controller.common;

import com.sky.constant.MessageConstant;
import com.sky.dto.UpdatePasswordDTO;
import com.sky.service.UpdatePasswordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Builder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.sky.result.Result;


@RestController
@RequestMapping("/updatePassword")
@Slf4j
@CrossOrigin
@Builder
@Api(tags = "通用接口(修改密码)")
public class UpdatePasswordController {

    @Autowired
    private UpdatePasswordService UpdatePasswordService;

    @PostMapping("/")
    @ApiOperation("修改密码")
    public Result<String> updatePassword(@RequestBody UpdatePasswordDTO updatePasswordDTO) {
        log.info("修改密码");
        boolean answer = UpdatePasswordService.updatePassword(updatePasswordDTO);
        if (answer) {
            return Result.success(MessageConstant.UPDATE_PASSWORD_SUCCESS);
        } else {
            return Result.error(MessageConstant.UPDATE_PASSWORD_FAIL);
        }
    }
}
